#include "settings.h"
#include <QSettings>

Settings::Settings(QObject *parent) : QObject(parent)
{

}

int Settings::protocolType(){
    return QSettings("config.ini", QSettings::IniFormat).value("protocolType", 0).toInt();
}

QString Settings::ip(){
    return QSettings("config.ini", QSettings::IniFormat).value("ip").toString();
}

int Settings::port(){
    return QSettings("config.ini", QSettings::IniFormat).value("port", 0).toInt();
}

bool Settings::recvHex(){
    return QSettings("config.ini", QSettings::IniFormat).value("recvHex", false).toBool();
}

bool Settings::logDisplayMode(){
    return QSettings("config.ini", QSettings::IniFormat).value("logDisplayMode", true).toBool();
}

bool Settings::autoNewline(){
    return QSettings("config.ini", QSettings::IniFormat).value("autoNewline", true).toBool();
}

bool Settings::hideRecv(){
    return QSettings("config.ini", QSettings::IniFormat).value("hideRecv", false).toBool();
}

bool Settings::autoScroll(){
    return QSettings("config.ini", QSettings::IniFormat).value("autoScroll", true).toBool();
}

bool Settings::sendHex(){
    return QSettings("config.ini", QSettings::IniFormat).value("sendHex", false).toBool();
}

QString Settings::remoteAddress(){
    return QSettings("config.ini", QSettings::IniFormat).value("remoteAddress").toString();
}

QString Settings::recvText(){
    return QSettings("config.ini", QSettings::IniFormat).value("recvText").toString();
}

QString Settings::sendText(){
    return QSettings("config.ini", QSettings::IniFormat).value("sendText").toString();
}

QString Settings::logFilename(){
    return QSettings("config.ini", QSettings::IniFormat).value("logFilename").toString();
}

bool Settings::outputToFile(){
    return QSettings("config.ini", QSettings::IniFormat).value("outputToFile", false).toBool();
}

bool Settings::addEnter(){
    return QSettings("config.ini", QSettings::IniFormat).value("addEnter", false).toBool();
}

bool Settings::addNewline(){
    return QSettings("config.ini", QSettings::IniFormat).value("addNewline", false).toBool();
}

int Settings::circle(){
    return QSettings("config.ini", QSettings::IniFormat).value("circle", 0).toInt();
}

void Settings::setProtocolType(int index){
    QSettings("config.ini", QSettings::IniFormat).setValue("protocolType", index);
}

void Settings::setIp(QString ip){
    QSettings("config.ini", QSettings::IniFormat).setValue("ip", ip);
}

void Settings::setPort(int port){
    QSettings("config.ini", QSettings::IniFormat).setValue("port", port);
}

void Settings::setRecvHex(bool enable){
    QSettings("config.ini", QSettings::IniFormat).setValue("recvHex", enable);
}

void Settings::setLogDisplayMode(bool enable){
    QSettings("config.ini", QSettings::IniFormat).setValue("logDisplayMode", enable);
}

void Settings::setAutoNewline(bool enable){
    QSettings("config.ini", QSettings::IniFormat).setValue("autoNewline", enable);
}

void Settings::setHideRecv(bool enable){
    QSettings("config.ini", QSettings::IniFormat).setValue("hiderRecv", enable);
}

void Settings::setSendHex(bool enable){
    QSettings("config.ini", QSettings::IniFormat).setValue("sendHex", enable);
}

void Settings::setRemoteAddress(QString address){
    QSettings("config.ini", QSettings::IniFormat).setValue("remoteAddress", address);
}

void Settings::setRecvText(QString text){
    QSettings("config.ini", QSettings::IniFormat).setValue("recvText", text);
}

void Settings::setSendText(QString text){
    QSettings("config.ini", QSettings::IniFormat).setValue("sendText", text);
}

void Settings::setLogFilename(QString filename){
    QSettings("config.ini", QSettings::IniFormat).setValue("logFilename", filename);
}

void Settings::setOutputFile(bool enable){
    QSettings("config.ini", QSettings::IniFormat).setValue("outputToFile", enable);
}

void Settings::setAddEnter(bool enable){
    QSettings("config.ini", QSettings::IniFormat).setValue("addEnter", enable);
}

void Settings::setAddNewline(bool enable){
    QSettings("config.ini", QSettings::IniFormat).setValue("addNewline", enable);
}

void Settings::setCircle(int millisecond){
    QSettings("config.ini", QSettings::IniFormat).setValue("circle", millisecond);
}

void Settings::setAutoScroll(bool enable){
    QSettings("config.ini", QSettings::IniFormat).setValue("autoScroll", enable);
}
